fad946
@@ -2661,6 +2661,10 @@
public GetHelper(String dbName, String tblName, boolean allowSql, boolean allowJ
       // the fallback from failed SQL to JDO is not possible.
       boolean isConfigEnabled = HiveConf.getBoolVar(getConf(), ConfVars.METASTORE_TRY_DIRECT_SQL)
           && (HiveConf.getBoolVar(getConf(), ConfVars.METASTORE_TRY_DIRECT_SQL_DDL) || !isInTxn);
+      if (isConfigEnabled && directSql == null) {
+        directSql = new MetaStoreDirectSql(pm, getConf());
+      }
+
       if (!allowJdo && isConfigEnabled && !directSql.isCompatibleDatastore()) {
         throw new MetaException("SQL is not operational"); // test path; SQL is enabled and broken.
       }
